package com.mh.rmi.service;

import com.mh.rmi.pojo.User;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.HashMap;
import java.util.Map;

public class UserServiceImpl extends UnicastRemoteObject implements IUserService{

    Map<Integer, User> userMap = new HashMap<>(4);

    public UserServiceImpl() throws RemoteException {
        super();
        User user1 = new User();
        user1.setId(1);
        user1.setName("Lucy");
        userMap.put(user1.getId(), user1);

        User user2 = new User();
        user2.setId(2);
        user2.setName("John");
        userMap.put(user2.getId(), user2);

    }

    @Override
    public User getByUserId(Integer id) throws RemoteException{
        return userMap.get(id);
    }
}
